﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TAP03
    {

        public TAP03()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VAPKOPF();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
        }

        public override void OnSave()
        {
            if (!IsSaved)
                return;
            if (dwMaster == null)
                return;
            TMV.UpdateAPKOPF(dwMaster,0);
            string key = KEY;
            KEY = "";
            KEY = key;
            base.OnSave();
        }

        public override void LOADBYAUF()
        { 
            if (ORDERNUM.Length < 8)
                return;
            dwData = TMV.TBMain.NewRow();
            dwData["APKMANDANT"] = app.Mandant;
            dwData["APKANRKRS"] = "AND APKANRKRS= '" + ORDERNUM.Substring(0, 2) + "'";
            dwData["APKALFDNR"] = "AND APKALFDNR= '" + ORDERNUM.Substring(2, 6) + "'"; 
            SResult = TMV.QAPK03(dwData);
            MergeData(SResult, true);
            base.LOADBYAUF();
        } 

    }
}
